package com.hzhr.iot.comm;

import com.hzhr.iot.comm.util.RedisUtil;
import com.hzhr.iot.core.constant.HzhrHeaderNames;
import com.hzhr.iot.core.util.HzhrStringUtils;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class Global implements CommandLineRunner {
    @Autowired
    RedisUtil redisUtil;

    private String token;

    @Override
    public void run(String... strings) throws Exception {
        //redisUtil.set("cyg", HzhrStringUtils.getGUID());
        System.out.println("***************获取token：");
        token = redisUtil.get("cyg").toString();
        System.out.println("***************全局token:" + token);
    }

    public String getToken() {
        return token;
    }

    public String getFirstToken() {
        String[] tokenSplit = token.split("_");
        return tokenSplit[0];
    }
}
